﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MealBooking.Core.Models.Accounts
{
    public class Account
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string Password { get; set; }
        public string EmailAddress { get; set; }
        public bool IsActived { get; set; }
        public DateTime RegisterTime { get; set; }
        public string Comment { get; set; }
        /// <summary>
        /// 该账号的所有权限
        /// </summary>
        public AccountRole Roles { get; set; }
    }
    /// <summary>
    /// 账号的权限, admin, user, etc. 用Role.Name作为ID
    /// </summary>
    public class RoleDetail
    {
        //public string Id { get; set; }
        public Role RoleName { get; set; }
        public string Description { get; set; }
    }
    /// <summary>
    /// role name, is enum,
    /// </summary>
    [Flags]
    public enum Role : int
    {
        /// <summary>
        /// admin
        /// </summary>
        Admin = 1,
        /// <summary>
        /// manager
        /// </summary>
        Manager = 2,
        /// <summary>
        /// actived User
        /// </summary>
        Customer = 4,
        /// <summary>
        /// not actived, only register
        /// </summary>
        User = 8,
    }

    /// <summary>
    /// 账号的密码, 独立存储
    /// </summary>
    public class AccountPsd
    {
        public string Id { get; set; }
        public string Password { get; set; }
    }
    /// <summary>
    /// account's role
    /// </summary>
    public class AccountRole
    {
        public string Id { get; set; }
        public int Roles { get; set; }
    }
    /// <summary>
    /// 可以订餐的用户, 即: 顾客
    /// </summary>
    public class Customer
    {
        /// <summary>
        /// Id为account的Id
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// Name为account的Name
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 余额
        /// </summary>
        public double Balance { get; set; }
        /// <summary>
        /// 信用额度
        /// </summary>
        public double Credit { get; set; }
    }

    public class Manager
    {
        /// <summary>
        /// Id为account的Id
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// Name为account的Name
        /// </summary>
        public string Name { get; set; }
    }

    public class BalanceHistory
    {
        public string Id { get; set; }
        public Account Account { get; set; }
        public Account OperatedBy { get; set; }
        public BalanceOperationType OperationType { get; set; }
        public double OldBalance { get; set; }
        public double NewBalance { get; set; }
        public double Amount { get; set; }
        public DateTime OperatedTime { get; set; }
        public string Comment { get; set; }
    }

    public enum BalanceOperationType
    {
        unknown,
        BookedOrder,
        AddBalance,
    }
}